using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using Facebook.Entity;

namespace DevicePhotoSample
{
    public partial class AlbumForm : Form
    {
        private MainForm parentForm;
        private Album album;

        public AlbumForm(MainForm parent, Album a)
        {
            InitializeComponent();

            parentForm = parent;
            this.album = a;

            
        }

        private void mnuPhoto_Click(object sender, EventArgs e)
        {
            Microsoft.WindowsMobile.Forms.CameraCaptureDialog ccd = new Microsoft.WindowsMobile.Forms.CameraCaptureDialog();
            ccd.Mode = Microsoft.WindowsMobile.Forms.CameraCaptureMode.Still;
            ccd.Title = "Add photo to Facebook";
            //ccd.Owner = this;
            ccd.Resolution = new Size(640, 480);
            //if success
            if (ccd.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileInfo fiImage = new System.IO.FileInfo(ccd.FileName);
                parentForm.facebookService1.UploadPhoto(album.AlbumId, fiImage);
                MessageBox.Show("Photo successfully uploaded", "Facebook Photos");
            }
        }

        private void AlbumForm_Load(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            lvAlbum.BeginUpdate();

            Collection<Photo> photos = parentForm.facebookService1.GetPhotos(album.AlbumId);
            int i = 0;
            foreach (Photo p in photos)
            {
                ListViewItem lvi = new ListViewItem(p.Caption);
                lvi.ImageIndex = i;
                ilAlbum.Images.Add(p.PictureSmall);
                lvAlbum.Items.Add(lvi);
                i++;
            }
            lvAlbum.EndUpdate();

            Cursor.Current = Cursors.Default;
        }
    }
}